#!/bin/bash

set -eux

proj_root=$(dirname $(dirname $(realpath $0)))

function build_ui() {
    cd ${proj_root}
    cd admin_web_ui
    docker build . -f Dockerfile -t ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_web_ui
    docker push ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_web_ui
}

function build_server() {
    cd ${proj_root}
    docker build . -f Dockerfile.server_deps -t ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_server_deps
    docker push ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_server_deps &

    docker build . -t ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_server
    docker push ccr.ccs.tencentyun.com/mkmk-common/ymk:ymk_store_system_server &
}

# build_ui
build_server
wait

docker image prune -f
